package design.book;

import design.decorate.Decorate;

public class Book implements Cloneable,Decorate{ //实体类实现克隆和装饰接口
	private String bid;
	private String bname;
	private String bauthor;
	private String btype;
	private Integer bprice;
	private Integer bamount;
	private String bpubdate;

	// Constructors

	/** default constructor */
	public Book() {
	}
	
	public Book(String bid, String bname, String bauthor, String btype, Integer bprice, Integer bamount,
			String bpubdate) {
		super();
		this.bid = bid;
		this.bname = bname;
		this.bauthor = bauthor;
		this.btype = btype;
		this.bprice = bprice;
		this.bamount = bamount;
		this.bpubdate = bpubdate;
	}

	public String getBid() {
		return this.bid;
	}

	public void setBid(String bid) {
		this.bid = bid;
	}

	public String getBname() {
		return this.bname;
	}

	public void setBname(String bname) {
		this.bname = bname;
	}

	public String getBauthor() {
		return this.bauthor;
	}

	public void setBauthor(String bauthor) {
		this.bauthor = bauthor;
	}

	public String getBtype() {
		return this.btype;
	}

	public void setBtype(String btype) {
		this.btype = btype;
	}

	public Integer getBprice() {
		return this.bprice;
	}

	public void setBprice(Integer bprice) {
		this.bprice = bprice;
	}

	public Integer getBamount() {
		return this.bamount;
	}

	public void setBamount(Integer bamount) {
		this.bamount = bamount;
	}

	public String getBpubdate() {
		return this.bpubdate;
	}

	public void setBpubdate(String bpubdate) {
		this.bpubdate = bpubdate;
	}
	
	public Book clone(){ //原型模式
		Book cpBook = null;
		try{
			cpBook = (Book)super.clone();
		}
		catch(CloneNotSupportedException e){
			e.printStackTrace();
		}
		return cpBook;
	}

	@Override
	public void borrow(String name) { //借书
		System.out.println("暂无借书人");
	}
	
	public String toString(){  //写到文件里的格式
		return "书号,"+getBid()+",书名,"+getBname()+",书作者,"+getBauthor()+",书类型,"+getBtype()+
				",价格,"+getBprice()+",数量,"+getBamount()+",出版时间,"+getBpubdate();
	}
	
	public String readString(){ //从文件读到控制台的格式
		return "书号: "+getBid()+" 书名: "+getBname()+" 书作者: "+getBauthor()+" 书类型: "+getBtype()+
				" 价格: "+getBprice()+" 数量: "+getBamount()+" 出版时间: "+getBpubdate();
	}
}
